<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link th:replace="fragments/dependency :: edit-css">

<title>优铺Admin</title>
</head>

<body>
<div class="right_col" style="background:#F7F7F7">
	<div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>添加商铺配套设施 </h2>
                    
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br>
                    <form id="demo-form2"  class="form-horizontal form-label-left">
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">
                        展示名称 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" name="name" required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                      </div>
                      <div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12">
							高亮图标预览 <span class="required"></span>
						</label>
						<div id="upload-file-preview" class="col-md-6 col-sm-6 col-xs-12">
							<span style="line-height: 36px;">未上传</span>
						</div>
					 </div>
							
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12">
							高亮图标 <span class="required"></span>
						</label>
						<div class="col-md-6 col-sm-6 col-xs-12">
							<div id="upload-picker">选择文件</div>
							<input type="hidden" name="highlightIco">
						</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">
								默认图标预览 <span class="required"></span>
							</label>
							<div id="upload-file-default" class="col-md-6 col-sm-6 col-xs-12">
								<span style="line-height: 36px;">未上传</span>
							</div>
						</div>
							
						<div class="form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">
								默认图标 <span class="required"></span>
							</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<div id="upload-picker_default">选择文件</div>
								<input type="hidden" name="defaultIco">
							</div>
						</div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >
                        排序 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text"  name="sort" required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
						  <button class="btn btn-primary" type="reset">重置</button>
                          <button type="button" id="save" class="btn btn-success">提交</button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
</div>
<div th:replace="fragments/dependency :: edit-js"></div>
	<script type="text/javascript">
	$(function() {
		var uploader = upUpload
				.createWithPreview(
						"https://static.ucaiworld.com/ueditor/jsp/controller.jsp?action=uploadimage",
						"upload-picker", "upload", 'upload-file-preview', 110, 110, adminLayer

				);
		uploader.startUpload = function() {
			
		}
		uploader.uploadAccept = function(obj, ret) {
			$("input[name=highlightIco]").val(ret.url).trigger("validate");
		}
		
		var uploader1 = upUpload
		.createWithPreview(
				"https://static.ucaiworld.com/ueditor/jsp/controller.jsp?action=uploadimage",
				"upload-picker_default", "upload", 'upload-file-default', 110, 110, adminLayer

		);
		uploader1.startUpload = function() {
			
		}
		uploader1.uploadAccept = function(obj, ret) {
			$("input[name=defaultIco]").val(ret.url).trigger("validate");
		}
	})
	
	var add={
			init:function(){
				add.initValidate();
				$("#save").on('click', function() {
					$('form').submit();
				});
			},
			initValidate : function() {
				formValidator.rules = {

				};

				formValidator.fields = {
					name : 'required;length(~8);',
					highlightIco : 'required;',
					defaultIco : 'required;',
					sort : 'integer;',
				};
				//表单提交的实体获取函数
				formValidator.getEntity = function() {
					return {
						name : $("input[name=name]").val(),
						highlightIco : $("input[name=highlightIco]").val(),
						defaultIco : $("input[name=defaultIco]").val(),
						sort : $("input[name=sort]").val(),
					};
				}
				//初始化验证路径以及回调函数
				formValidator.init('/shopSupporting/add', function(data) {
					if (data.id > 0) {
						adminLayer.alert({
							content : '添加成功',
							yes : function() {
								window.parent.location.reload();
							},
							end : function() {
								
							}
						});
					}
				});
			}
	}
	add.init();
	</script>
	
	
</body>
</html>
